package cn.class2.demo8.ysz

import java.io.File

import scala.io.Source

/**
  * Created by lzd on 2018/11/28.
  */
class RichFile(file: File) {
  def read(): String = Source.fromFile(file).mkString
}

object RichFile {
  def main(args: Array[String]): Unit = {
    //    val content = new File("/").read()
    //显示的装饰
    val content = new RichFile(new File("D:\\1688\\diqu.txt")).read()
    println(content)

    println("===============================")

    import MyPreDef.file2RichFile
    //隐式的装饰
    val content2 = new File("D:\\1688\\diqu.txt").read()
    println(content2)

  }
}
